# Define Macros

FC = mpixlf90_r # ftn # mpif90 #ftn
FC = mpif90

EXE = ../bin/cfoam_bgq

#pgi
#FCFLAGS = -O3 -Minfo -Mneginfo -fast  -Munroll=n:4 -Mipa=fast,inline -tp bulldozer
#FCFLAGS =  -O3 -Minfo -Mneginfo -fast  -Munroll=n:4 -Mipa=fast,inline  
#cray
#FCFLAGS = -O3 -Oaggress -Omsgs
#gnu
#FCFLAGS = -Ofast -funroll-loops -ftree-vectorize -ftree-vectorizer-verbose=5
#FCFLAGS = -O3 # -O0 -C -g -traceback
FCFLAGS = -O3 -g -qhot
FCOMPFLAGS = -O3 -qsmp -qhot -g
LDFLAGS = -O3 -qhot -g -qsmp
FCFLAGS = -O3 
FCOMPFLAGS = -O3 
LDFLAGS = -O3 

LIBS = -L/home/morozov/lib -lmpihpm_smp -L/bgsys/drivers/ppcfloor/bgpm/lib -lbgpm
LIBS =

##WORKSPACE = workspace

OBJS =  Data_Acoustics.o Data_cfoam.o Data_Faces.o \
        Data_Jacobians.o Data_Mesh.o \
	Data_Time.o Data_Transducer.o \
	Data_Sources.o PerfectGas.o \
	PR_CalcNozzleBoundCond.o \
	version.o \
	signalC.o timemeasure.o \
	PR_MinMaxWrite.o \
	PR_CalcPointsFacesCellsNeigForVisc.o PR_CalcCorrectorStep.o\
	PR_CalcViscousFluxes.o \
	PR_AcousticsSurfInit.o     PR_OutputDataFromAllProcs.o \
	PR_AfterReadContourData.o  PR_OutputTransducerDataInit.o \
	PR_CalcChars.o             PR_OutputTransducerData.o \
	PR_OutputTransducerAsynData.o PR_SourceDeltaFunction.o\
	PR_CalcFacesVariables_A.o    PR_ReadContourData.o \
	PR_CalcFluxes.o            PR_ReadMeshOpenFOAM.o \
	PR_CalcGradU.o             PR_SetInitConditions.o \
	PR_CalcJacobians.o         PR_TransformVars2Chars.o \
	PR_CalcLocalSteps.o        PR_usdef1_A.o \
	Def_p_1.o                  PR_CalcNodeInterface.o     PR_usdef1_TotalPresTempGiven.o \
	Def_p_conv.o               PR_CalcNoiseSignal.o       PR_usdef3.o \
	meshCellDefinition.o       PR_usdefn.o \
	PR_InputRestart.o          ReadDataFile.o \
       PR_WriteResFiles.o         PR_ReadResFiles.o\
       PR_DefineNextFileName.o\
	c3dFoam_allcharnewpost1.o PR_coor.o

all :  $(OBJS) ../source/c3dFoam_allcharnewpost1.f90
	$(FC) $(LDFLAGS) -o $(EXE) $(OBJS) $(LIBS)

# Dependencies

PR_coor.o: ../source/PR_coor.f90
	$(FC) $(FCFLAGS) -c $< -o $@

c3dFoam_allcharnewpost1.o: ../source/c3dFoam_allcharnewpost1.f90 ../source/phase1_sak.H
	$(FC) -c $(FCFLAGS) ../source/c3dFoam_allcharnewpost1.f90 

PR_WriteResFiles.o: ../source/OutputData/PR_WriteResFiles.f90
	$(FC) -c $(FCFLAGS) ../source/OutputData/PR_WriteResFiles.f90

PR_ReadResFiles.o: ../source/ReadInput/PR_ReadResFiles.f90
	$(FC) -c $(FCFLAGS) ../source/ReadInput/PR_ReadResFiles.f90

PR_DefineNextFileName.o: ../source/Utils/PR_DefineNextFileName.f90
	$(FC) -c $(FCFLAGS) ../source/Utils/PR_DefineNextFileName.f90

PR_usdefn.o: ../source/PR_usdefn.F90
	$(FC) -c $(FCFLAGS) ../source/PR_usdefn.F90

PR_usdef1_A.o: ../source/PR_usdef1_A.F90
	$(FC) -c $(FCFLAGS) ../source/PR_usdef1_A.F90

PR_usdef3.o: ../source/PR_usdef3.F90
	$(FC) -c $(FCFLAGS) ../source/PR_usdef3.F90

PR_usdef1_TotalPresTempGiven.o: ../source/PR_usdef1_TotalPresTempGiven.F90
	$(FC) -c $(FCFLAGS) ../source/PR_usdef1_TotalPresTempGiven.F90

PR_TransformVars2Chars.o: ../source/CABARET/AsynchronousTimeIntegration/PR_TransformVars2Chars.F90
	$(FC) -c $(FCFLAGS) ../source/CABARET/AsynchronousTimeIntegration/PR_TransformVars2Chars.F90

PR_SetInitConditions.o: ../source/ReadInput/PR_SetInitConditions.f90
	$(FC) -c $(FCFLAGS) ../source/ReadInput/PR_SetInitConditions.f90

PR_ReadMeshOpenFOAM.o: ../source/ReadInput/PR_ReadMeshOpenFOAM.f90
	$(FC) -c $(FCFLAGS) ../source/ReadInput/PR_ReadMeshOpenFOAM.f90

PR_ReadContourData.o: ../source/SurfAcoustics/PR_ReadContourData.f90
	$(FC) -c $(FCFLAGS) ../source/SurfAcoustics/PR_ReadContourData.f90

PR_OutputTransducerAsynData.o: ../source/Transducers/PR_OutputTransducerAsynData.f90
	$(FC) -c $(FCFLAGS) ../source/Transducers/PR_OutputTransducerAsynData.f90

PR_SourceDeltaFunction.o: ../source/PrelimanyCalculations/PR_SourceDeltaFunction.f90
	$(FC) -c $(FCFLAGS) ../source/PrelimanyCalculations/PR_SourceDeltaFunction.f90

PR_OutputTransducerDataInit.o: ../source/Transducers/PR_OutputTransducerDataInit.f90
	$(FC) -c $(FCFLAGS) ../source/Transducers/PR_OutputTransducerDataInit.f90

PR_OutputTransducerData.o: ../source/Transducers/PR_OutputTransducerData.f90
	$(FC) -c $(FCFLAGS) ../source/Transducers/PR_OutputTransducerData.f90

PR_OutputDataFromAllProcs.o: ../source/OutputData/PR_OutputDataFromAllProcs.F90
	$(FC) -c $(FCFLAGS) ../source/OutputData/PR_OutputDataFromAllProcs.F90

ReadDataFile.o: ../source/ReadDataFile.F90
	$(FC) -c $(FCFLAGS) ../source/ReadDataFile.F90

PR_InputRestart.o: ../source/PR_InputRestart.F90
	$(FC) -c $(FCFLAGS) ../source/PR_InputRestart.F90

PR_CalcNoiseSignal.o: ../source/SurfAcoustics/PR_CalcNoiseSignal.f90
	$(FC) -c $(FCFLAGS) ../source/SurfAcoustics/PR_CalcNoiseSignal.f90

PR_CalcNodeInterface.o: ../source/PR_CalcNodeInterface.F90
	$(FC) -c $(FCOMPFLAGS) ../source/PR_CalcNodeInterface.F90

PR_CalcLocalSteps.o: ../source/CABARET/AsynchronousTimeIntegration/PR_CalcLocalSteps.F90
	$(FC) -c $(FCFLAGS) ../source/CABARET/AsynchronousTimeIntegration/PR_CalcLocalSteps.F90

PR_CalcJacobians.o: ../source/CABARET/PR_CalcJacobians.F90
	$(FC) -c $(FCFLAGS) ../source/CABARET/PR_CalcJacobians.F90

PR_CalcGradU.o: ../source/CABARET/PR_CalcGradU.F90
	$(FC) -c $(FCFLAGS) ../source/CABARET/PR_CalcGradU.F90

PR_CalcFluxes.o: ../source/CABARET/AsynchronousTimeIntegration/PR_CalcFluxes.F90
	$(FC) -c $(FCFLAGS) ../source/CABARET/AsynchronousTimeIntegration/PR_CalcFluxes.F90

PR_CalcFacesVariables_A.o: ../source/CABARET/PR_CalcFacesVariables_A.F90
	$(FC) $(FCOMPFLAGS) -c $< -o $@

PR_CalcChars.o: ../source/CABARET/AsynchronousTimeIntegration/PR_CalcChars.F90
	$(FC) -c $(FCFLAGS) ../source/CABARET/AsynchronousTimeIntegration/PR_CalcChars.F90

PR_CalcPointsFacesCellsNeigForVisc.o: ../source/PrelimanyCalculations/PR_CalcPointsFacesCellsNeigForVisc.f90
	$(FC) -c $(FCFLAGS) ../source/PrelimanyCalculations/PR_CalcPointsFacesCellsNeigForVisc.f90

PR_CalcViscousFluxes.o: ../source/CABARET/AsynchronousTimeIntegration/PR_CalcViscousFluxes.f90
	$(FC) -c $(FCFLAGS) ../source/CABARET/AsynchronousTimeIntegration/PR_CalcViscousFluxes.f90

PR_CalcCorrectorStep.o: ../source/CABARET/AsynchronousTimeIntegration/PR_CalcCorrectorStep.f90
	$(FC) -c $(FCFLAGS) ../source/CABARET/AsynchronousTimeIntegration/PR_CalcCorrectorStep.f90

PR_MinMaxWrite.o: ../source/OutputData/PR_MinMaxWrite.f90
	$(FC) -c $(FCFLAGS) ../source/OutputData/PR_MinMaxWrite.f90

timemeasure.o: ../source/Utils/timemeasure.f90
	$(FC) -c $(FCFLAGS) ../source/Utils/timemeasure.f90

signalC.o: ../source/Utils/signalC.f90
	$(FC) -c $(FCFLAGS) ../source/Utils/signalC.f90

version.o: ../source/version.f90
	$(FC) -c $(FCFLAGS) ../source/version.f90

PR_CalcNozzleBoundCond.o: ../source/PR_CalcNozzleBoundCond.F90
	$(FC) -c $(FCFLAGS) ../source/PR_CalcNozzleBoundCond.F90

PerfectGas.o: ../source/PerfectGas.F90
	$(FC) -c $(FCFLAGS) ../source/PerfectGas.F90

Data_Sources.o: ../source/Data_Sources.f90
	$(FC) -c $(FCFLAGS) ../source/Data_Sources.f90

PR_AfterReadContourData.o: ../source/SurfAcoustics/PR_AfterReadContourData.f90
	$(FC) -c $(FCFLAGS) ../source/SurfAcoustics/PR_AfterReadContourData.f90

PR_AcousticsSurfInit.o: ../source/SurfAcoustics/PR_AcousticsSurfInit.f90
	$(FC) -c $(FCFLAGS) ../source/SurfAcoustics/PR_AcousticsSurfInit.f90

meshCellDefinition.o: ../source/meshCellDefinition.f90
	$(FC) -c $(FCFLAGS) ../source/meshCellDefinition.f90

Def_p_conv.o: ../source/Def_p_conv.f90
	$(FC) -c $(FCFLAGS) ../source/Def_p_conv.f90

Def_p_1.o: ../source/Def_p_1.f90
	$(FC) -c $(FCFLAGS) ../source/Def_p_1.f90

Data_Transducer.o: ../source/Transducers/Data_Transducer.f90
	$(FC) -c $(FCFLAGS) ../source/Transducers/Data_Transducer.f90

Data_Time.o: ../source/Data_Time.f90
	$(FC) -c $(FCFLAGS) ../source/Data_Time.f90

Data_Mesh.o: ../source/Data_Mesh.f90
	$(FC) -c $(FCFLAGS) ../source/Data_Mesh.f90

Data_Jacobians.o: ../source/CABARET/Data_Jacobians.F90
	$(FC) -c $(FCFLAGS) ../source/CABARET/Data_Jacobians.F90

Data_Faces.o: ../source/Data_Faces.f90
	$(FC) -c $(FCFLAGS) ../source/Data_Faces.f90

Data_cfoam.o: ../source/Data_cfoam.f90
	$(FC) -c $(FCFLAGS) ../source/Data_cfoam.f90

Data_Acoustics.o: ../source/SurfAcoustics/Data_Acoustics.f90
	$(FC) -c $(FCFLAGS) ../source/SurfAcoustics/Data_Acoustics.f90




clean :: 
	rm -f $(OBJS)
	rm -f *.mod
	rm -f $(EXE)


